<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="query.keyword" placeholder="请输入关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="search">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="name" label="姓名" width="180">
			</el-table-column>
			<el-table-column prop="url" label="URL" width="180">
			</el-table-column>
			<el-table-column prop="sn" label="唯一标识" width="180">
			</el-table-column>
			<el-table-column prop="descs" label="描述" width="180">
			</el-table-column>
			<el-table-column prop="pname.name" label="父权限" min-width="180" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
      <el-pagination
          layout="prev, pager, next"
          @current-change="handleCurrentChange"
          :page-size="query.pageSize"
          :total="pageInfo.total"
          :current-page="query.currentPage"
          style="float:right;">
      </el-pagination>
		</el-col>

	</section>
</template>

<script>

	export default {
		data() {
			return {
				filters: {
					name: ''
				},
				total: 0,
				page: 1,
				listLoading: false,
				sels: [],//列表选中列

        query:{
          currentPage:1,  // 当前页
          pageSize:10, // 每页显示条数
          keyword:""  // 关键字-查询条件
        },
        pageInfo:{
          total:0,  // 总条数
          rows:[] // 当前页数据
        }
			}
		},
		methods: {
      search(){
        this.query.currentPage = 1
        this.getPermission()
      },
      handleCurrentChange(val) {
				this.query.currentPage = val;
        console.log(this.query.currentPage)
				this.getPermission();
			},
      selsChange: function (sels) {
        this.sels = sels;
      },
			//获取用户列表
			getPermission() {
				this.$http.post("/permission",this.query).then(result =>{
				  result = result.data
          if(result.success){
            this.pageInfo = result.data
          }else {
            this.$message({message:result.message,type:'error'})
          }
        }).catch(result =>{
          this.$message({message: "网络异常,请检查网络!",type: 'error'});
        })
			},
		},
		mounted() {
			this.getPermission();
		}
	}

</script>

<style scoped>

</style>